package com.easydisk.constant;


import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * 角色常量枚举
 */
public class UserRoleEnum {
   public enum UserRole{
       /**
        * 角色类型枚举类
        */
       USR_ROLE_0(0, "普通用户"),
       USR_ROLE_1(1, "普通用户"),
       USR_ROLE_2(2, "管理员");

       UserRole(Integer code, String name) {
           this.code = code;
           this.name = name;
       }

       private static Map<Integer,String> map=new HashMap<>();

       static {
           for (UserRole userRole : UserRole.values()) {
               map.put(userRole.code, userRole.name);
           }
       }

       private final Integer code;
       private final String name;

       public Integer getCode() {
           return code;
       }

       public String getName() {
           return name;
       }

       public static String getUserRolebyCode(Integer code) {
           return map.get(code);
       }
   }
}
